Skip to content

Conversation

@PeteLawler
Copy link
Collaborator

Introduce get-version.sh to consistently derive Semantic Versions from Git state across local and CI environments. Key capabilities:

  • Robust SemVer derivation:

    • Supports vMAJOR.MINOR.PATCH[-prerelease] tags.
    • When on a tagged commit: emits the exact SemVer.
    • When ahead of a tag: appends build metadata with the commit count since the tag (e.g., +N).
    • When no tags exist: defaults to 0.0.0+.
    • Optional explicit version argument to override tag discovery when needed.
  • CI-friendly and hardened behavior:

    • set -euo pipefail and sanitized IFS for safer shell execution.
    • Works in shallow clones by attempting to fetch tags/unshallow; falls back gracefully.
    • Handles absence of Git or non-repo directories by emitting a safe default and continuing.
    • Emits SemVer and ShortSha to GITHUB_OUTPUT when available for downstream GitHub Actions steps.
  • Assembly version stamping (best-effort):

    • Computes AssemblyVersion, AssemblyFileVersion, and AssemblyInformationalVersion.
    • Informational version includes branch and full SHA for traceability.
    • Updates AssemblyInfo.cs files only if Perl is available; otherwise skips with a warning (avoids hard dependency).
  • Minimal external dependencies:

    • Requires only Git; Perl is optional and used solely for in-place file updates.
  • Other information:

Introduce get-version.sh to consistently derive Semantic Versions from Git state across local and CI environments.
Key capabilities:
- Robust SemVer derivation:
    - Supports vMAJOR.MINOR.PATCH[-prerelease] tags.
    - When on a tagged commit: emits the exact SemVer.
    - When ahead of a tag: appends build metadata with the commit count since the tag (e.g., +N).
    - When no tags exist: defaults to 0.0.0+.
    - Optional explicit version argument to override tag discovery when needed.

- CI-friendly and hardened behavior:
    - set -euo pipefail and sanitized IFS for safer shell execution.
    - Works in shallow clones by attempting to fetch tags/unshallow; falls back gracefully.
    - Handles absence of Git or non-repo directories by emitting a safe default and continuing.
    - Emits SemVer and ShortSha to GITHUB_OUTPUT when available for downstream GitHub Actions steps.

- Assembly version stamping (best-effort):
    - Computes AssemblyVersion, AssemblyFileVersion, and AssemblyInformationalVersion.
    - Informational version includes branch and full SHA for traceability.
    - Updates AssemblyInfo.cs files only if Perl is available; otherwise skips with a warning (avoids hard dependency).

- Minimal external dependencies:
    - Requires only Git; Perl is optional and used solely for in-place file updates.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants